/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package network;

import Core.PaymentsLogic;
import DTO.OfflinePayment;

import com.simpay.cashierandroidapp.R;

/**
 * 
 * @author Minh Hung
 */
public class LiveThread extends Thread {

	private static LiveThread instance;
	public static boolean send_queue = false;
	public static boolean send_request = false;
	public static boolean send_po = false;
	public static boolean send_mess = false;
	int time_request;
	int time_message;
	int time = 0;

	private LiveThread() {
		try {
			time_request = 3000;
			time_message = 60000;
			time = time_message;
		} catch (Exception ex) {
			time_request = 3000;
			time_message = 600000;
		}
		start();
	}

	public static LiveThread getInstance() {
		if (instance == null) {
			instance = new LiveThread();
		}

		return instance;
	}

//	public void run() {
//		while (true) {
//			if (send_queue) {
//				if (PaymentsLogic.getIns().haveQueue()) {
//					send_queue = false;
//					new NetworkThread(Packet.TYPE_GETPAYMENTSTATUS, 0, null);
//				}
//			}
//			if (send_request) {
//				if (PaymentsLogic.getIns().haveRequest()) {
//					send_request = false;
//					new NetworkThread(Packet.TYPE_SENDPAYMENTS, 0, null);
//				}
//			}
//
//			if (send_po) {
//				if (PaymentsLogic.getIns().havePO()) {
//					send_po = false;
//					new NetworkThread(Packet.TYPE_PURCHASEONLINE, 0, null);
//				}
//			}
//
//			if (send_mess) {
//				time += time_request;
//				if (time >= time_message) {
//					send_mess = false;
//					time = 0;
//					new NetworkThread(Packet.TYPE_GETMESSAGES,
//							0);
//				}
//			}
//
//			try {
//				sleep(time_request);
//			} catch (InterruptedException ex) {
//				ex.printStackTrace();
//			}
//		}
//	}
}
